from wagtail.api.v2.serializers import PageSerializer
from rest_framework import serializers
from .models import Author, BlogPage


class AuthorSerializer(serializers.ModelSerializer):
    class Meta:
        model = Author
        fields = ['id', 'name', 'author_image']


class BlogPageSerializer(PageSerializer):
    authors = AuthorSerializer(many=True)

    class Meta:
        model = BlogPage
        fields = ['id', 'title', 'date', 'intro', 'body', 'authors']
